package com.myway.service.impl;

import com.myway.dao.SysFootColumnMapper;
import com.myway.dao.SysPortalNewsMapper;
import com.myway.dto.param.ContentParam;
import com.myway.pojo.SysFootColumn;
import com.myway.pojo.SysPortalNews;
import com.myway.vo.ContentVo;
import com.myway.service.ContentService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * Created by yufei on 2018/1/17.
 */
@Service
@Slf4j
public class ContentServiceImpl implements ContentService {

    @Autowired
    private SysFootColumnMapper sysFootColumnMapper;

    @Autowired
    private SysPortalNewsMapper sysPortalNewsMapper;
    @Override
    public ContentVo page(ContentParam param) {
        List<SysPortalNews> sysPortalNewsList = sysPortalNewsMapper.selectByType(param.getType());

        List<SysFootColumn> sysFootColumnList = sysFootColumnMapper.selectByType(param.getParentType());

        int count = sysPortalNewsMapper.count(param.getType());

        ContentVo contentVo = ContentVo.builder().sysFootColumnList(sysFootColumnList).sysPortalNewsList(sysPortalNewsList)
                .total(count).build();
        return contentVo;
    }
}
